package com.my.mall.manage.evaluate.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.my.mall.common.R;
import com.my.mall.manage.evaluate.dto.EvaluateManageDTO;
import com.my.mall.manage.evaluate.service.EvaluateManageService;
import com.my.mall.manage.evaluate.vo.EvaluateManageVo;

@Controller
@RequestMapping("manage/evaluate")
public class EvaluateManageController {
	@Autowired
	EvaluateManageService evaluateManageService;

	@RequestMapping("selectEvaluateList")
	@ResponseBody
	public Map<String, Object> selectEvaluateList(EvaluateManageDTO evaluate, int iDisplayStart, int iDisplayLength) {
		List<EvaluateManageVo> list = evaluateManageService.selectEvaluateList(evaluate, iDisplayStart, iDisplayLength);
		int size = evaluateManageService.selectEvaluateCount(evaluate);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("iTotalRecords", size);
		map.put("iTotalDisplayRecords", size);
		map.put("aaData", list);
		return map;
	}

	@RequestMapping("getEvaluate/{id}")
	@ResponseBody
	public R getEvaluate(@PathVariable("id") int id) {
		EvaluateManageVo evaluateDate = evaluateManageService.getEvaluate(id);
		return R.ok().put("evaluateDate", evaluateDate);
	}

	@RequestMapping("updateEvaluateReply")
	@ResponseBody
	public R updateEvaluateReply(EvaluateManageDTO evaluate) {
		int result = 0;
		result = evaluateManageService.updateEvaluateReply(evaluate);
		if (result == 1)
			return R.ok();
		else
			return R.error("系统故障！");
	}

}